package com.kind.springboot.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.kind.springboot.common.interceptor.AuthorizationInterceptor;
import com.kind.springboot.common.resolvers.CurrentUserMethodArgumentResolver;

import java.util.List;

/**
 * 
 * Function:配置类，增加自定义拦截器和解析器. <br/>
 * Date:     2016年8月11日 下午1:10:49 <br/>
 * @author   weiguo21
 * @version  
 * @since    JDK 1.7
 * @see
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private AuthorizationInterceptor authorizationInterceptor;

    @Autowired
    private CurrentUserMethodArgumentResolver currentUserMethodArgumentResolver;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorizationInterceptor);
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(currentUserMethodArgumentResolver);
    }
}
